#pragma once

#include "messagebase.h"
#include "Message.h"
#include "GameFwd.h"
#include "AbstractMessageFactory.h"
#include "GalconClient.h"

class MessageFactory : public AbstractMessageFactory
{
public:

   MessageFactory(GalconClientPtr galconClient, GamePtr gamePtr, boost::shared_ptr<QGraphicsView> graphicsView);

   ~MessageFactory();

protected:

   virtual MessageBasePtr do_parseMessage( MessagesEnum, split_vector_type_iter, split_vector_type_iter );

private:
   GalconClientPtr m_galconPtr;
   boost::shared_ptr<QGraphicsView> m_graphicsView;
   GamePtr m_gamePtr;
   template<typename Iter>
   MessageBasePtr buildInitialGameStateMessage(Iter begin, Iter end);
   template<typename Iter>
   MessageBasePtr builGameStateMessage(Iter begin, Iter end);
   template<typename Iter>
   MessageBasePtr buildShipsLaunchedMessage(Iter begin, Iter end);
   template<typename Iter>
   MessageBasePtr buildErrorDescriptionMessage(Iter begin, Iter end);
   template<typename Iter>
   MessageBasePtr buildRejectionMessage(Iter begin, Iter end);
};



typedef boost::shared_ptr<MessageFactory> MessageFactoryPtr;